# https://www.bilibili.com/video/BV1W7411G7wP/?p=8&spm_id_from=pageDriver&vd_source=8bd7b24b38e3e12c558d839b352b32f4
# 
import pandas as pd
import copy

students = pd.read_excel('../resources/input_py_tools/007-008/008/Students.xlsx')
students2 = copy.copy(students)
students3 = copy.copy(students)
#print(students)

def age_between_18_30(a):
    return 18 <= a < 30

def level_a(s):
    return 85 <= s <= 100

# 年龄>=18且<30, 分数>=85的学生
students = students.loc[students['Age'].apply(age_between_18_30)].loc[students['Score'].apply(level_a)]
print(students)

# 写法2
students2 = students2.loc[students2.Age.apply(age_between_18_30)].loc[students2.Score.apply(level_a)]
print(students2)

# 写法3
students3 = students3.loc[students3.Age.apply(lambda a: 18 <= a < 30)] \
    .loc[students3.Score.apply(lambda s: 85 <= s <= 100)]
print(students3)
